package com.stu_ques.question.pojo;

import java.io.Serializable;
import java.util.Date;

import com.stu_ques.common.util.DateUtil;
import com.stu_ques.users.pojo.Student;

/**
 * 	答案表的属性:	id,学生id,答案,是否正确,创建时间,结束时间
 * */
public class Answer	implements Serializable
{
	/*	回答表的ID	*/
	private int id;
	/*	问题的ID	*/
	private int questionId;
	/*	学生表的id	*/
	private int studentId;
	/*	对错	*/
	private String rightAndWrong;
	/*	答案	*/
	private String answer;
	/*	创建时间	*/
	private Date creationTime;
	/*	更新时间	*/
	private Date updateTime;
	/*	表的关联关系	*/
	/*	一个答案对应一个问题	*/
	private Question question;
	/*	一个答案对应一个学生	*/
	private Student student;
	/*	生成读写器	*/
	public int getId()
	{
		return id;
	}
	public void setId(int id)
	{
		this.id = id;
	}
	public int getStudentId()
	{
		return studentId;
	}
	public void setStudentId(int studentId)
	{
		this.studentId = studentId;
	}
	public String getRightAndWrong()
	{
		return rightAndWrong;
	}
	public void setRightAndWrong(String rightAndWrong)
	{
		this.rightAndWrong = rightAndWrong;
	}
	public Date getCreationTime()
	{
		return creationTime;
	}
	public void setCreationTime(Date creationTime)
	{
		this.creationTime = creationTime;
	}
	public Date getUpdateTime()
	{
		return updateTime;
	}
	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}
	public String getAnswer()
	{
		return answer;
	}
	public void setAnswer(String answer)
	{
		this.answer = answer;
	}
	public int getQuestionId()
	{
		return questionId;
	}
	public void setQuestionId(int questionId)
	{
		this.questionId = questionId;
	}
	public Question getQuestion()
	{
		return question;
	}
	public void setQuestion(Question question)
	{
		this.question = question;
	}
	public Student getStudent()
	{
		return student;
	}
	public void setStudent(Student student)
	{
		this.student = student;
	}
	@Override
	public String toString()
	{
		/*	实现问题表的关联关系	*/
		String quesName = "无";
		if(this.question != null)
		{
			quesName = this.question.getName();
			if(quesName.length() >=3)
			{
				quesName = quesName.substring(0, 3)+"...";
			}
		}
		/*	实现学生表的关联关系	*/
		String studentName = "无";
		if(student != null)
		{
			studentName = this.student.getName();
		}
		DateUtil dateUtil = new DateUtil();
		String str = this.getId()+"\t"+quesName+"\t"+studentName+"\t"+this.getRightAndWrong()+"\t"+this.getAnswer()+"\t"
				+dateUtil.dateTimeString(this.getCreationTime())+"\t"+dateUtil.dateTimeString(this.getUpdateTime());
		return str;
	}
}
